package main

import (
	"fmt"
	mqtt "github.com/eclipse/paho.mqtt.golang"
)

func onMsgHandler(client mqtt.Client, message mqtt.Message) {
	fmt.Println(string(message.Payload()))
}

func onConnect (client mqtt.Client) {
	fmt.Println("connected")
}

func main(){
	//config := mqtt.ClientOptions{}
	//config.AddBroker("tcp://www.dcharles.top:1883")
	//config.SetClientID("device_change" + strconv.Itoa(rand.Intn(1000000)))
	//config.SetOnConnectHandler(onConnect)
	////config.SetDefaultPublishHandler(onMsgHandler)
	//mqttclient := mqtt.NewClient(&config)
	//if token := mqttclient.Connect();token.Wait() && token.Error() != nil {
	//	fmt.Println(token.Error())
	//}
	////topic1 := "GATEWAY/change"
	//topic2 := "GATEWAY/data"
	//for  {
	//	token := mqttclient.Subscribe(topic2, 0, onMsgHandler)
	//	token.Wait()
	//}
	var res []interface{}
	res = append(res, "str", "str1")
	for index, content := range res {
		fmt.Println(index)
		fmt.Println(content)
	}
}
